package jp.seraph.jsade.perceptor;

import java.util.ArrayList;
import java.util.List;

public class SeePerceptor implements Perceptor {
    public SeePerceptor(SeeObject... aObjects) {
        mObjects = new ArrayList<SeeObject>(aObjects.length);
        for (int i = 0; i < aObjects.length; i++)
            if (aObjects[i] != null)
                mObjects.add(aObjects[i]);
    }

    private List<SeeObject> mObjects;

    /**
     * 
     * @see jp.seraph.jsade.perceptor.Perceptor#accept(jp.seraph.jsade.perceptor.PerceptorVisitor)
     */
    public void accept(PerceptorVisitor aVisitor) {
        aVisitor.visit(this);
    }

    public int getCount() {
        return mObjects.size();
    }

    public SeeObject getObject(int aIndex) {
        return mObjects.get(aIndex);
    }

    public SeeObject getLeftGoal1() {
        return this.getSeeObject(SeeObjectType.LEFT_GOAL_1);
    }

    public SeeObject getLeftGoal2() {
        return this.getSeeObject(SeeObjectType.LEFT_GOAL_2);
    }

    public SeeObject getRightGoal1() {
        return this.getSeeObject(SeeObjectType.RIGHT_GOAL_1);
    }

    public SeeObject getRightGoal2() {
        return this.getSeeObject(SeeObjectType.RIGHT_GOAL_2);
    }

    public SeeObject getLeftField1() {
        return this.getSeeObject(SeeObjectType.LEFT_FIELD_1);
    }

    public SeeObject getLeftField2() {
        return this.getSeeObject(SeeObjectType.LEFT_FIELD_2);
    }

    public SeeObject getRightField1() {
        return this.getSeeObject(SeeObjectType.RIGHT_FIELD_1);
    }

    public SeeObject getRightField2() {
        return this.getSeeObject(SeeObjectType.RIGHT_FIELD_2);
    }

    public SeeObject getBall() {
        return this.getSeeObject(SeeObjectType.BALL);
    }

    public List<SeeObject> getPlayers() {
        List<SeeObject> tResult = new ArrayList<SeeObject>();
        for (SeeObject tObj : mObjects)
            if (tObj.getType() == SeeObjectType.PLAYER)
                tResult.add(tObj);

        return tResult;
    }

    public SeeObject getSeeObject(SeeObjectType aType) {
        for (SeeObject tObj : mObjects)
            if (tObj.getType() == aType)
                return tObj;

        return null;
    }
}
